import React from 'react';
import _ from 'lodash'
import Like from "../common/like.jsx";
const TBody = ({ data, columns }) => {
    const rederCell = (item, column) => {
        if (column.content) {
            return column.content(item)
        } else {
            return _.get(item, column.path)
        }
    }

    const createKey = (item, column) => {
        return item.id + (column.path || column.key)
    }

    return (
        <tbody>
        {data.map(item => (
            <tr key={item.id}>
                {columns.map(col => (
                    <td key={createKey(item, col)}>{rederCell(item, col)}</td>
                ))}
            </tr>
        ))}
        </tbody>
    );
};

export default TBody;
